<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>选择医生床位</title>
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/themes/default/easyui.css"/>">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/themes/icon.css"/>">
	
	<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
</head>
<body>
	<script type="text/javascript">
		$(function(){
			$("#ck").linkbutton({onClick:function(){
				var rows = $("#tb-rz").datagrid("getSelections");
				if(rows.length == 1){
					$("#his_brxx").window("open");
					var brNo = rows[0].brNo;
					$.getJSON("brxx", {"brNo": brNo}, function(data){
						$("#form-brxx").form("load", data);
					});
				}
				else{
					$.messager.alert("提示", "只能选择一条记录，您目前选择了" + rows.length + "条!");
				}
				
				$('#form-brxx').form("clear");
				
			}});
			
			
				$("#xzcw").linkbutton({onClick:function(){
					var rows = $("#tb-rz").datagrid("getSelections");
					if(rows.length == 1){
						if(rows[0].cwNo==null){
						$("#his_cw").window("open");
						var bqNo = rows[0].bqNo;
						var url = 'cw?bqNo='+bqNo
						$("#tb-cw").datagrid({url: url});}
						else{
							$.messager.alert("提示", "该病人已选择了床位");
						}
					}
					else{
						$.messager.alert("提示", "只能选择一条记录，您目前选择了" + rows.length + "条!");
					}
				}});
				
				
				$("#xzys").linkbutton({onClick:function(){
					var rows = $("#tb-rz").datagrid("getSelections");
					if(rows.length == 1){
						if(rows[0].zyysNo==null){
						$("#his_ys").window("open");
						var bqNo = rows[0].bqNo;
						var url = 'ys?bqNo='+bqNo
						$("#tb-ys").datagrid({url: url});}
						else{
							$.messager.alert("提示", "该病人已选择了医生");
						}
					}
					else{
						$.messager.alert("提示", "只能选择一条记录，您目前选择了" + rows.length + "条!");
					}
				}});
			
				
				
				$("#qrcw").linkbutton({onClick:function(){
					var rows = $("#tb-rz").datagrid("getSelections");
					var rowcw = $("#tb-cw").datagrid("getSelections");
					if(rowcw.length == 1){
						var brNo = rows[0].brNo;
						var cwNo = rowcw[0].cwNo;
						$.getJSON("xzcw", {"brNo": brNo,"cwNo":cwNo}, function(data){
							//var json = eval("(" + data + ")");
							$.messager.alert("提示", data.reason);							
						});
						//关闭窗口
						$("#his_cw").window("close");
						//重新加载数据
						$("#tb-rz").datagrid("reload");						
					}
					else{
						$.messager.alert("提示", "只能选择一条记录，您目前选择了" + rowcw.length + "条!");
					}}});
				
				
				$("#qrys").linkbutton({onClick:function(){
					var rows = $("#tb-rz").datagrid("getSelections");
					var rowys = $("#tb-ys").datagrid("getSelections");
					if(rowys.length == 1){
						var brNo = rows[0].brNo;
						var ysNo = rowys[0].zyysNo;
						$.getJSON("xzys", {"brNo": brNo,"ysNo":ysNo}, function(data){
							
							$.messager.alert("提示", data.reason);							
						});
						//关闭窗口
						$("#his_ys").window("close");
						//重新加载数据
						$("#tb-rz").datagrid("reload");						
					}
					else{
						$.messager.alert("提示", "只能选择一条记录，您目前选择了" + rowys.length + "条!");
					}}});
			
				//根据患者姓名搜索
				$('#rz-search').searchbox({
				    searcher:function(value,name){
				    	$("#tb-rz").datagrid({
				    		url: 'selectBrname', 
				    		method: 'post', 
				    		queryParams: {
				    			name: value
				    		}});
				    }
				});
			
				//显示全部待选择病人
				$("#xsrz").linkbutton({onClick:function(){
					$("#tb-rz").datagrid({
	    			url: 'patientAll', 
	    			method: 'get'
	    			});
				}});
				
		
				
				
				
		});
	</script>


	<table id="tb-rz" class="easyui-datagrid" 
		data-options="url:'patientAll',
			fitColumns:true,fit:true,
			pagination: true,
			pageSize: 5,
			pageList: [5, 10, 15, 20],
			rownumbers: true,
			singleSelect:true,
			
			toolbar: '#rzgjl'
			">
		<thead>
			<tr>
				<th data-options="field:'brNo',width:'3%', checkbox: true">病人号</th>
				<th data-options="field:'brName', align:'center', width:'15%'">病人姓名</th>
				<th data-options="field:'ylkNo', align:'center', width:'15%'">医疗卡号</th>
				<th data-options="field:'brSituation', align:'center',width:'15%'">病人情况</th>
				<th data-options="field:'ksmc',align:'center',width:'15%'">科室</th>
				<th data-options="field:'bqNo',align:'center',width:'5%'">科室号</th>
				<th data-options="field:'cwNo',align:'center',width:'5%'">床位号</th>
				<th data-options="field:'zyysNo',align:'center',width:'5%'">医生号</th>
			</tr>
		</thead>
	</table>
	
		<!--工具栏-->
	<div id="rzgjl">
		<a  id="xsrz" class="easyui-linkbutton" data-options="iconCls:'icon-xsqb',plain:true">显示全部</a>
		<a  id="ck" class="easyui-linkbutton" data-options="iconCls:'icon-ck',plain:true">查看病人信息</a>
		<a  id="xzcw" class="easyui-linkbutton" data-options="iconCls:'icon-bc',plain:true">选择床位</a>
		<a  id="xzys" class="easyui-linkbutton" data-options="iconCls:'icon-ys',plain:true">选择医生</a>
		
		
		
		<input  id="rz-so" class="easyui-searchbox" data-options="prompt:'请输入',menu:'#mm',searcher:doSearch" style="width:300px"></input>

		<div id="mm" >
		<div data-options="name:'xm'">姓名</div>
		<div data-options="name:'ylkNo'">医疗卡号</div>
		</div>
	</div>
	
		<script>
		var url ;
		$(function(){
			doSearch();
			$("#mm").menu({
				onClick:function(itme){
					url =	(itme.name == 'xm' ? 'selectBrname' : 'selectYlkno');	
					
				}
			});
		})
		function doSearch(value,name){
			$('#rz-so').searchbox({
			    searcher:function(value,name){
			    	$("#tb-rz").datagrid({
			    		url:url, 
			    		method: 'post', 
			    		queryParams: {
			    			ss: value
			    		}});
			    }
			});
			
		}
	</script>
	<!--选择床位-->
	<div id="his_cw" class="easyui-window" title="选择床位"  data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-xz',closed: true" 
				style="width:400px;height:350px;padding:0px;">
			<table id="tb-cw" class="easyui-datagrid" 
					data-options="
								  fitColumns:true,fit:true,
								  pagination: false,
								  pageSize: 5,
								  pageList: [5, 10, 15, 20],
								  rownumbers: false,
								  singleSelect:true,
								  toolbar: '#cwgjl'
			">
			<thead>
				<tr>
					<th data-options="field:'cwNo',width:'3%', checkbox: true">床位编号</th>
					<th data-options="field:'cwid',width:'35%'">床位号</th>
					<th data-options="field:'cwRent',width:'35%'">床位租金</th>
				</tr>
			</thead>
		</table>
		<div id="cwgjl">
		<a  id="qrcw" class="easyui-linkbutton" data-options="iconCls:'icon-qr',plain:true">确认</a>
		</div>
	</div>
	
		<!--选择医生-->
	<div id="his_ys" class="easyui-window" title="选择医生"  data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-xz',closed: true" 
				style="width:400px;height:350px;padding:0px;">
			<table id="tb-ys" class="easyui-datagrid" 
					data-options="
								  fitColumns:true,fit:true,
								  pagination: false,
								  pageSize: 5,
								  pageList: [5, 10, 15, 20],
								  rownumbers: false,
								  singleSelect:true,
								  toolbar: '#ysgjl'
			">
			<thead>
				<tr>
					<th data-options="field:'zyysNo',width:'3%', checkbox: true">医生编号</th>
					<th data-options="field:'zyysName',width:'35%'">医生名称</th>
					<th data-options="field:'zyysJob',width:'35%'">医生职务</th>
				</tr>
			</thead>
		</table>
		<div id="ysgjl">
		<a  id="qrys" class="easyui-linkbutton" data-options="iconCls:'icon-qr',plain:true">确认</a>
		</div>
	</div>
	
	
	<div id="his_brxx" class="easyui-window" title="查看病人信息"  data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-xx',closed: true" 
				style="width:300px;height:370px;padding:5px;">
			
				<form id="form-brxx" action="" method="post" >
					<div class="item"><input name="brName"   readonly="readonly"  class="easyui-textbox" data-options="label: '病人姓名：', width: 200"></div>
					<div class="item"><input name="brAge" readonly="readonly"  class="easyui-textbox" data-options="label: '年龄：', width: 200"></div>
					<div class="item"><input name="brSex" readonly="readonly" class="easyui-textbox" data-options="label: '性别：', width: 200"></div>
					<div class="item"><input name="brTel" readonly="readonly" class="easyui-textbox" data-options="label: '联系方式：', width: 200"></div>
					<div class="item"><input name="brAddress" readonly="readonly" class="easyui-textbox" data-options="label: '家庭住址：', width: 230"></div>
					<div class="item"><input name="brIdnumber" readonly="readonly" class="easyui-textbox" data-options="label: '身份证号：', width: 230"></div>
					<div class="item"><input name="ylkNo" readonly="readonly" class="easyui-textbox" data-options="label: '医疗卡号', width: 200"></div>
					<div class="item"><input name="ksmc" readonly="readonly" class="easyui-textbox " data-options="label: '科室：', width: 200"></div>
					<div class="item"><input name="brSituation" readonly="readonly" class="easyui-textbox" data-options="label: '病人情况：', width: 200"></div>
					<div class="item"><input name="cwNo" readonly="readonly" class="easyui-textbox" data-options="label: '床位', width: 200"></div>
					<div class="item"><input name="zyysNo" readonly="readonly" class="easyui-textbox" data-options="label: '住院医生', width: 200"></div>
					<div class="item"><input name="brDate" readonly="readonly" class="easyui-textbox" data-options="label: '入院时间：', width: 200"></div>
				</form>
			
	</div>

	
</body>
</html>